home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed fades ƒ / Circular fade reversed.c next >
Encoding:
C/C++ Source or Header  |  1994-01-12  |  3.7 KB  |  134 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Circular fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 2
  32. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  33. #define theWindowWidth (boundsRect.right-boundsRect.left)
  34.  
  35. pascal short CircularFadeReversed(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* Trace a region from the center to the topleft corner, down <BlockSize> pixels,
  38.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  39.    Repeat for all sides (counterclockwise). */
  40.  
  41. pascal short CircularFadeReversed(Rect boundsRect, Pattern *thePattern)
  42. {
  43.     RgnHandle    curregion, boundsRgn, sectrgn;
  44.     int            cx,cy,lastx,lasty;
  45.     int            BlockSize;
  46.     
  47.     BlockSize=theWindowWidth/40;
  48.     cx = boundsRect.left + theWindowWidth / 2;
  49.     cy = boundsRect.top + theWindowHeight / 2;
  50.  
  51.     boundsRgn=NewRgn();
  52.     SetRectRgn(boundsRgn, boundsRect.left, boundsRect.top, boundsRect.right, boundsRect.bottom);
  53.     
  54.     sectrgn=NewRgn();
  55.     curregion=NewRgn();
  56.     lasty=boundsRect.top;
  57.     do                                            /* left quadrant */
  58.     {
  59.         StartTiming();
  60.         SetEmptyRgn(curregion);
  61.         MoveTo(cx,cy);
  62.         OpenRgn();
  63.             LineTo(boundsRect.left,lasty);
  64.             Line(0, BlockSize);
  65.             LineTo(cx,cy);
  66.         CloseRgn(curregion);
  67.         SectRgn(curregion, boundsRgn, sectrgn);
  68.         FillRgn(sectrgn, *thePattern);
  69.         lasty+=BlockSize;
  70.         TimeCorrection(CorrectTime);
  71.     }
  72.     while (lasty<boundsRect.bottom);
  73.     
  74.     lastx=boundsRect.left;
  75.     do                                            /* bottom quadrant */
  76.     {
  77.         StartTiming();
  78.         SetEmptyRgn(curregion);
  79.         MoveTo(cx,cy);
  80.         OpenRgn();
  81.             LineTo(lastx,boundsRect.bottom);
  82.             Line(BlockSize, 0);
  83.             LineTo(cx,cy);
  84.         CloseRgn(curregion);
  85.         SectRgn(curregion, boundsRgn, sectrgn);
  86.         FillRgn(sectrgn, *thePattern);
  87.         lastx+=BlockSize;
  88.         TimeCorrection(CorrectTime);
  89.     }
  90.     while (lastx<boundsRect.right);
  91.     
  92.     lasty=boundsRect.bottom;
  93.     do                                            /* right quadrant */
  94.     {
  95.         StartTiming();
  96.         SetEmptyRgn(curregion);
  97.         MoveTo(cx,cy);
  98.         OpenRgn();
  99.             LineTo(boundsRect.right,lasty);
  100.             Line(0,-BlockSize);
  101.             LineTo(cx,cy);
  102.         CloseRgn(curregion);
  103.         SectRgn(curregion, boundsRgn, sectrgn);
  104.         FillRgn(sectrgn, *thePattern);
  105.         lasty-=BlockSize;
  106.         TimeCorrection(CorrectTime);
  107.     }
  108.     while (lasty>boundsRect.top-BlockSize);
  109.     
  110.     lastx=boundsRect.right;
  111.     do                                            /* top quadrant */
  112.     {
  113.         StartTiming();
  114.         SetEmptyRgn(curregion);
  115.         MoveTo(cx,cy);
  116.         OpenRgn();
  117.             LineTo(lastx,boundsRect.top);
  118.             Line(-BlockSize,0);
  119.             LineTo(cx,cy);
  120.         CloseRgn(curregion);
  121.         SectRgn(curregion, boundsRgn, sectrgn);
  122.         FillRgn(sectrgn, *thePattern);
  123.         lastx-=BlockSize;
  124.         TimeCorrection(CorrectTime);
  125.     }
  126.     while (lastx>boundsRect.left-BlockSize);
  127.     
  128.     DisposeRgn(curregion);
  129.     DisposeRgn(boundsRgn);
  130.     DisposeRgn(sectrgn);
  131.     
  132.     return 0;
  133. }
  134.